<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <button>click</button>
</body>
<script>
  function fn() {
    console.log(this)
  }
  function debounce(fn, time) {
    let timer
    return function (...args) {
      if (timer) clearTimeout(timer)
      timer = setTimeout(function () {
        fn.apply(this, args)
      }, time)
    }
  }
  document.querySelector('button').addEventListener('click', () => {
    debounce(fn, 5000)
  })
</script>

</html>